package com.hzdesk.media.matvector.koreabatch.client.my_paperless.adapter;

import android.content.Context;
import android.view.View;

import com.hzdesk.media.matvector.koreabatch.client.my_paperless.R;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.base.BaseAdapter;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.base.BaseViewHolder;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.bean.DevicesCustomConfigurationBean;
import com.hzdesk.media.matvector.koreabatch.client.my_paperless.view_holder.ManageProfilesPagerViewHolder;


/**
 * Created by Administrator on 2018/8/15.
 * 杭州席媒科技有限公司  Developers  刘传华  10
 * 佛祖镇楼 bug辟易
 */

public class ManageProfilesPagerAdapter<T> extends BaseAdapter {

    public ManageProfilesPagerAdapter(Context mContext) {
        super(mContext);
    }

    @Override
    protected int getItemLayout() {
        return R.layout.manage_profiles_pager;
    }

    @Override
    protected BaseViewHolder getItemViewHolder(View view) {
        return new ManageProfilesPagerViewHolder(view);
    }

    @Override
    protected void onMyBindViewHolder(BaseViewHolder holder, final int position) {
        ManageProfilesPagerViewHolder manageProfilesPagerViewHolder = (ManageProfilesPagerViewHolder) holder;
        DevicesCustomConfigurationBean bean = (DevicesCustomConfigurationBean) mlist.get(position);
        manageProfilesPagerViewHolder.getTv_name().setText(bean.getName());
       int currenUse =  bean.getCurrentUse();
       if(currenUse == 1){
           manageProfilesPagerViewHolder.getIv_personal_open().setImageResource(R.mipmap.personal_open);
       }else{
           manageProfilesPagerViewHolder.getIv_personal_open().setImageResource(R.mipmap.personal_close);
       }
        manageProfilesPagerViewHolder.getIv_delect_config().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(mIonClickedItemListenter != null){
                    mIonClickedItemListenter.onClickedFist(position);
                }
            }
        });
        manageProfilesPagerViewHolder.getIv_personal_open().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(mIonClickedItemListenter != null){
                    mIonClickedItemListenter.onClickedSecond(position);
                }
            }
        });
    }

    @Override
    public int getItemCount() {
        int count = super.getItemCount();
        if(count > 5){
            return 5;
        }else {
            return count;
        }
    }
}
